package org.example.utils;


import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.net.InetSocketAddress;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @description:
 * @author: feixiang.li
 * @date: 2025-01-03 10:24
 */
@Slf4j
public class ServiceUtils {

    private ServiceUtils(){

    }

    public static final Map<String, InetSocketAddress> serviceRegistry = new ConcurrentHashMap<>();


    /**
     * 注册服务
     *
     * @param serviceName       服务名
     * @param inetSocketAddress Socket地址
     */
    public static void registerService(String serviceName, InetSocketAddress inetSocketAddress) {
        serviceRegistry.put(serviceName, inetSocketAddress);
    }

    public static InetSocketAddress getService(String serviceName) {
        return serviceRegistry.get(serviceName);
    }
}
